let computed = {
  locatHost: function () {
    let arr = this.form.devHost;
    return arr.join('.');
  },
  optsProtocol: function () {
    return ['http', 'https'].map((v, i) => {
      return { label: v, value: v, key: i };
    });
  }, //协议
  optsHostname: function () {
    let opts = [`${this.locatHost}`];
    opts.push(
      ...this.HostAndPost.map(v => {
        return v.host;
      }),
    );
    return opts.map((v, i) => {
      return { label: v, value: v, key: i };
    });
  }, //主机
  optsPost: function () {
    let opts = [`${this.form.devPost}`];
    opts.push(
      ...this.HostAndPost.map(v => {
        return v.port;
      }),
    );
    return opts.map((v, i) => {
      return { label: v, value: v, key: i };
    });
  }, //端口
  optsPathname: function () {
    let opts = ['/'];
    opts.push(
      ...this.HostAndPost.map(v => {
        return v.pathname;
      }),
    );
    return opts.map((v, i) => {
      return { label: v, value: v, key: i };
    });
  }, // 路径,通常是FTP对应路径
  optsEnterFile: function () {
    let opts = ['index.html'];

    return opts.map((v, i) => {
      return { label: v, value: v, key: i };
    });
  },
  optsRouter: function () {
    let copy = this.routes;
    let opts = copy.reduce((t, v, i, a) => {
      if (v.children) {
        v.children.forEach(v1 => {
          let fp = v.path == '/' ? '' : `${v.path}`;
          t.push(
            Object.assign(v1, {
              path: `${fp}/${v1.path}`,
            }),
          );
        });
      } else {
        t.push(v);
      }
      return t;
    }, []);
    return opts;
  },
  comHref: function () {
    let href = `${this.form.protocol}://${this.form.hostname}:${this.form.post}${this.form.pathname}${this.form.enterFile}#`;
    return href;
  },
  comQuery: function () {
    let r = this.form.query.reduce((t, v, i, a) => {
      if (v.isUsed) {
        t.push(`${v.key}=${v.value}`);
      }
      return t;
    }, []);
    if (r.length === 0) {
      return '';
    } else {
      return `${r.join('&')}`;
    }
  },
  realHrefs: function () {
    let hrefs = [
      {
        name: '基准文件',
        href: `${this.form.protocol}://${this.form.hostname}:${this.form.post}${this.form.pathname}server_config.js`,
      },
    ];
    this.optsRouter.forEach(v => {
      let q = this.comQuery.length === 0 ? '' : `?${this.comQuery}`;
      hrefs.push({
        name: v.name,
        href: `${this.comHref}${v.path}${q}`,
      });
    });
    return hrefs;
  },
};
